<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/xml; charset=UTF-8"/>
    <title>Stemwijzer JSONP test</title>
    <script type="text/javascript">
	function submitJsonp(userName) {
		var url = "public/register/"+userName+"?callback=displayResult";
		var script = document.createElement('script');
		script.setAttribute('src', url);
		document.getElementsByTagName('head')[0].appendChild(script); 
	}
    
    function displayResult(response) {
		document.getElementById('result').innerHTML = response;
    }
    </script>
  </head>
  <body>
    <FORM action="javascript:void(0);" onsubmit="submitJsonp(document.getElementById('userName').value);">
		<input type="text" name="userName" id="userName" />
		<button onclick="document.forms[0].submit();">Submit</button>
	</FORM>
	<div id="result"></div>
  </body>
 </html>